package com.ruoyi.wechat.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wechat.domain.DynamicImg;
import com.ruoyi.wechat.service.IDynamicImgService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * dynamicImgController
 * 
 * @author yeluochen
 * @date 2024-12-24
 */
@RestController
@RequestMapping("/wx/dynamicImg")
public class DynamicImgController extends BaseController
{
    @Autowired
    private IDynamicImgService dynamicImgService;

    /**
     * 查询dynamicImg列表
     */
    @PreAuthorize("@ss.hasPermi('wechat:dynamicImg:list')")
    @GetMapping("/list")
    public TableDataInfo list(DynamicImg dynamicImg)
    {
        startPage();
        List<DynamicImg> list = dynamicImgService.selectDynamicImgList(dynamicImg);
        return getDataTable(list);
    }

    /**
     * 导出dynamicImg列表
     */
    @PreAuthorize("@ss.hasPermi('wechat:dynamicImg:export')")
    @Log(title = "dynamicImg", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DynamicImg dynamicImg)
    {
        List<DynamicImg> list = dynamicImgService.selectDynamicImgList(dynamicImg);
        ExcelUtil<DynamicImg> util = new ExcelUtil<DynamicImg>(DynamicImg.class);
        util.exportExcel(response, list, "dynamicImg数据");
    }

    /**
     * 获取dynamicImg详细信息
     */
    @PreAuthorize("@ss.hasPermi('wechat:dynamicImg:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(dynamicImgService.selectDynamicImgById(id));
    }

    /**
     * 新增dynamicImg
     */
    @PreAuthorize("@ss.hasPermi('wechat:dynamicImg:add')")
    @Log(title = "dynamicImg", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DynamicImg dynamicImg)
    {
        return toAjax(dynamicImgService.insertDynamicImg(dynamicImg));
    }

    /**
     * 修改dynamicImg
     */
    @PreAuthorize("@ss.hasPermi('wechat:dynamicImg:edit')")
    @Log(title = "dynamicImg", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DynamicImg dynamicImg)
    {
        return toAjax(dynamicImgService.updateDynamicImg(dynamicImg));
    }

    /**
     * 删除dynamicImg
     */
    @PreAuthorize("@ss.hasPermi('wechat:dynamicImg:remove')")
    @Log(title = "dynamicImg", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dynamicImgService.deleteDynamicImgByIds(ids));
    }
}
